#region imports

using System;
using System.Text;
using System.ComponentModel;
using System.Xml;
using System.Xml.Serialization;
using System.Collections.Generic;
using MimeCloud.AssetManagement.Business.Interface;

#endregion

namespace MimeCloud.AssetManagement.Business
{
    [Serializable]
    public class RelatedAsset : IRelatedAsset
    {
        #region properties

        [XmlElement ( "id" )]
        public int ID { get; set; }

        [XmlIgnore]
        public int AssetID { get; set; }

        [XmlIgnore]
        public int RelatedAssetID { get; set; }

        [XmlIgnore]
        public int StatusID { get; set; }

        [XmlElement ( "createddate" )]
        public DateTime CreatedDate { get; set; }

        [XmlElement ( "udpateddate" )]
        public DateTime UpdatedDate { get; set; }

        [XmlElement ( "Status" )]
        public IStatus Status { get; set; }

        [XmlElement ( "Asset" )]
        public IAsset Asset { get; set; }

        [XmlElement ( "RelatedAsset" )]
        public IAsset Related { get; set; }

        #endregion

        #region constructors

        public RelatedAsset ( ) { }

        public RelatedAsset ( int id , int assetId , int relatedAssetId , int statusId , DateTime created , DateTime updated )
        {
            this.ID = id;
            this.AssetID = assetId;
            this.RelatedAssetID = relatedAssetId;
            this.StatusID = statusId;
            this.CreatedDate = created;
            this.UpdatedDate = updated;
        }

        public RelatedAsset ( IRelatedAsset entity )
        {
            this.ID = entity.ID;
            this.AssetID = entity.AssetID;
            this.RelatedAssetID = entity.RelatedAssetID;
            this.StatusID = entity.StatusID;
            this.CreatedDate = entity.CreatedDate;
            this.UpdatedDate = entity.UpdatedDate;
        }

        #endregion

        #region overridden methods

        public override string ToString ( )
        {
            StringBuilder str = new StringBuilder ( );

            str.Append ( "-> ID: " + this.ID.ToString ( ) );
            str.Append ( "-> AssetID: " + this.AssetID.ToString ( ) );
            str.Append ( "-> RelatedAssetID: " + this.RelatedAssetID.ToString ( ) );
            str.Append ( "-> StatusID: " + this.StatusID.ToString ( ) );
            if ( this.CreatedDate != null ) str.Append ( "-> CreatedData: " + this.CreatedDate.ToShortDateString ( ) );
            if ( this.UpdatedDate != null ) str.Append ( "-> UpdatedData: " + this.UpdatedDate.ToShortDateString ( ) );

            return str.ToString ( );
        }

        #endregion
    }
}
